﻿using System;
using System.Collections.Generic;
using System.Text;
using AppSocketEntity.User;
using Dapper;
using System.Data;

namespace AppSocketData.User
{
    public class UserData : IUserData
    {
        private readonly ISqlCommand sqlCommand;
        public UserData(ISqlCommand sqlCommand)
        {
            this.sqlCommand = sqlCommand;
        }

        public UserEntity GetUserByUserId(long userId)
        {
            string sql = @"SELECT UserId,Phone,Password FROM Users WHERE UserId=?UserId";
            DynamicParameters parameters = new DynamicParameters();
            parameters.Add("?UserId", userId, DbType.Int64);

            return this.sqlCommand.QueryEntity<UserEntity>(sql, CommandType.Text, parameters);
        }
    }
}
